package com.client.koshercook.client;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
/** user history recipes */
public class UserHistory extends RecsAndLinksBox {

	private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
	
	public UserHistory() {
		super("הסטוריה");
		open.setUrl("history_off.gif");
		open.setSize("132px", "24px");
		open.addMouseOverHandler(new MouseOverHandler(){
			public void onMouseOver(MouseOverEvent event) {
				open.setUrl("history_on.gif");
			}
		});
		open.addMouseOutHandler(new MouseOutHandler(){
			public void onMouseOut(MouseOutEvent event) {
				open.setUrl("history_off.gif");
			}
		});
		open.setTitle("היסטורית המתכונים שצפיתם בהם");
	}

	/** get the user information from the server */
	protected void getData() {
		greetingService.getUserViewdedRecipes(new AsyncCallback<List<String>>() {
			public void onFailure(Throwable caught) {
			}
			public void onSuccess(List<String> result) {
				fillTable(result);
			}
		});
	}
	
	protected void off(){
		open.setUrl("history_off.gif");
	}
}	